<template>
<div class="comment">
  <div class="head">
    <h2>发表评论</h2>
    <van-button size="small" round type="warning" @click="release">&nbsp&nbsp发&nbsp&nbsp布&nbsp&nbsp</van-button>
  </div>
  <div class="content">

  <h1>{{detail.title}}</h1>
  <van-tag type="warning">{{ detail.style === 1 ? "老房" : "新房" }}</van-tag>
  <van-tag type="warning">{{detail.area}}㎡</van-tag>
  <van-tag type="warning">{{detail.value}}</van-tag>
    <div class="score">
  <van-rate void-color="#FFFFFFFF" v-model="value" />
    </div>
    <van-field
        v-model="message"
        rows="2"
        type="textarea"
        maxlength="50"
        placeholder="请输入评论"
        show-word-limit
    />
  </div>
</div>
</template>

<script>
import {post} from "../assets/js/config/api"
import {mapState} from "vuex"
export default {
  name: "Comment",
  data(){
    return{
      message:'',
      value:3,
      orderId:'',
      id:this.$route.params.id,
      detail:{},
      params:{},
      data:{},
    }
  },

  computed:{
    ...mapState(["uid","uname"])
  },

  mounted() {
    console.log(this.orderId,this.uid)
    this.params={
    user:this.uid,
      id:this.id
    }
    post('/list',this.params).then(result=>{
      console.log(result.result[0])
      this.detail=result.result[0]
      this.orderId=result.result[0].orderId
    })
  },



  methods:{
   release(){
     if(this.message){
       this.data={
         orderId:this.orderId,
         user:this.uid,
         name:this.uname,
         score:this.value,
         style:this.detail.style,
         area:this.detail.area,
         value:this.detail.value,
         content:this.message,
       }
       console.log(this.data)
       post('/release',this.data).then(
           ()=>{this.$router.push('/')}
       )
     }
     }

  }





}
</script>

<style scoped lang="scss">
@import "public/sass/comment";
</style>
